<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@page import="org.jeecgframework.web.util.StaticValue" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<html>
<head>
    <title>商务服务单详情</title>
    <style type="text/css">
        .noSelect {
            border: 0;
            /*display: block;*/
            /*position: relative;*/
            min-height: 1.146667rem;
            line-height: 1.146667rem;
            white-space: nowrap;
            /*width: 100%;*/
            overflow: hidden;
            padding-right: .6rem;
            background-color: #eee;
            background: transparent;
            appearance: none;
            -moz-appearance: none; /* Firefox */
            -webkit-appearance: none; /* Safari 和 Chrome */
        }
    </style>
</head>
<body>
<div style="margin-bottom:10px;">
    <img style="margin-bottom:-7px" src="plug-in/login/images/dispatch bill.png">
    <span class="list-title">${cbsService.code}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <span style="font-size:13px;">服务进度：<span class="color-red">
        ${cbsService.speed}
    </span></span>
    <div style="position: absolute; text-align: center; width: 100%; margin-top:-20px;">
        <a href="#" class="easyui-linkbutton l-btn" onclick="findEngineer('${cbsService.id}')">派单</a>
        <a href="#" class="easyui-linkbutton l-btn" onclick="refuseEngineer('${cbsService.id}')">拒绝</a>
        <a href="#" class="easyui-linkbutton l-btn" onclick="checkCompletionReport()">查看完工报告</a>
    </div>
</div>

<div class="subtitle">
    <p>服务描述</p>
    <input type="hidden" name="cbsId" id="cbsId" value="${cbsService.id}">
    <table class="nobordertable noborder">
        <tbody>
        <tr>
            <td class="al_r" width="20%">
                <label>服务类型:</label>
            </td>
            <td width="30%">
                ${cbsService.t1Name}》${cbsService.t2Name}
            </td>
            <td class="al_r" width="20%">
                <label>级别:</label>
            </td>
            <td width="30%">
                ${cbsService.level}
            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%">
                <label>故障代码:</label>
            </td>
            <td width="30%">
                ${cbsService.errorCode}
            </td>
            <td class="al_r" width="20%">
                <label>故障照片:</label>
            </td>
            <td width="30%">
                <c:if test="${not empty zyFileLogEntityA}">
                    <c:forEach items="${zyFileLogEntityA}" var="a">
                        <div href="#" onclick="downloadFile('${a.id}')">
                            <input type="hidden" id="fileIdas" value='${a.id}'>
                            <span style="color:blue;" id='${a.id}'><a class="color-blue"
                                                                      href="fileUploadController.do?downLoadFile&fileLogId=${a.id}">${a.oldFileName }</a></span>
                        </div>
                    </c:forEach>
                </c:if>
            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%">
                <label>客户需求描述:</label>
            </td>
            <td width="30%">
                ${cbsService.description}
            </td>
            <td class="al_r" width="20%">
                <label>巴可HD处理过程:</label>
            </td>
            <td width="30%">
                ${cbsService.handleDes}
            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%">
                <label>工程师级别:</label>
            </td>
            <td width="30%">
                ${cbsService.authentication}
            </td>
            <td class="al_r" width="20%">
                <label>派单要求:</label>
            </td>
            <td width="30%">
                ${cbsService.assign_des}
            </td>
        </tr>
        </tbody>
    </table>
    <div style="width: 98%; margin: 10px auto;">附加任务</div>
    <table class="ftable">
        <tbody>
        <tr>
            <th>对象</th>
            <th>待办内容</th>
        </tr>
        <c:forEach items="${cbsServiceTaskMap}" var="task">
            <tr>
                <td>${task.attachTaskId.objectName}</td>
                <td>${task.attachTaskId.content}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<div class="subtitle">
    <p>客户信息</p>
    <table class="nobordertable noborder" style="border: none;">
        <tbody>
        <tr>
            <td class="al_r" width="20%">
                <label>联系人电话:</label>
            </td>
            <td width="30%">
                ${cbsService.phone}
            </td>
            <td class="al_r" width="20%">
                <label>联系人邮箱:</label>
            </td>
            <td width="30%">
                ${cbsService.email}
            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%">
                <label>联系人姓名:</label>
            </td>
            <td width="30%">
                ${cbsService.name}
            </td>
            <td class="al_r" width="20%">

            </td>
            <td width="30%">

            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%">
                <label>影院名称:</label>
            </td>
            <td width="30%">
                ${cbsService.ciName}
            </td>
            <td class="al_r" width="20%">
                <label>院线:</label>
            </td>
            <td width="30%">
                ${cbsService.type_intheater_name}
            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%">
                <label>影院地址:</label>
            </td>
            <td width="30%">
                ${cbsService.address}
            </td>
            <td class="al_r" width="20%">

            </td>
            <td width="30%">

            </td>
        </tr>
        <tr>
            <td class="al_r"></td>
            <td colspan="3">
                <span class="color-org">提示：</span><span class="color-hui">此地址是系统记录地址，请与客户核实准确地址。</span>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<div class="subtitle">
    <p>设备信息</p>
    <table class="nobordertable noborder" style="border: none;">
        <tbody>
        <tr>
            <td class="al_r" width="20%">
                <label>设备序列号:</label>
            </td>
            <td width="30%">
                ${cbsService.sn}
            </td>
            <td class="al_r" width="20%">
                <label>设备型号:</label>
            </td>
            <td width="30%">
                ${cbsService.type_desc}
            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%">
                <label>保修期状态:</label>
            </td>
            <td width="30%">
                ${cbsService.inReparirDateVal}
            </td>
            <td class="al_r" width="20%">
                <label>激光改造:</label>
            </td>
            <td width="30%">
                ${cbsService.laser}
            </td>
        </tr>
        </tbody>
    </table>
</div>
<div class="subtitle">
    <p>备件申请</p>
    <table class="ftable">
        <tr>
            <th>备件申请单号</th>
            <th>备件类型</th>
            <th>备件号</th>
            <th>备件数量</th>
            <th>申请理由</th>
            <th>审批状态</th>
            <th>预计到货时间</th>
            <th>发货状态</th>
            <th>物流</th>
        </tr>
        <c:forEach items="${equipmentList}" var="a">
            <tr>
                <td>${a[0]}</td>
                <td>${a[5]}</td>
                <td>${a[6]}</td>
                <td>${a[7]}</td>
                <td>${a[1]}</td>
                <td>
                    <c:if test="${a[8]==1}">待审批</c:if>
                    <c:if test="${a[8]==2}">已通过</c:if>
                    <c:if test="${a[8]==3}">
                        <div title="${a[9]}">未通过</div>
                    </c:if>
                </td>
                <td>${a[2]}</td>
                <td>
                    <c:if test="${a[3]==1}">CSA待发货</c:if>
                    <c:if test="${a[3]==2}">CSA已发货</c:if>
                    <c:if test="${a[3]==3}">CSA取消发货</c:if>
                    <c:if test="${a[3]==4}">欠货中</c:if>
                    <c:if test="${a[3]==5}">物流待发货</c:if>
                    <c:if test="${a[3]==6}">物流待签收</c:if>
                    <c:if test="${a[3]==7}">已签收</c:if>
                </td>
                <td>${a[4]}</td>
            </tr>
        </c:forEach>
    </table>
</div>
<div class="subtitle">
    <p>服务日志</p>
    <table class="ftable">
        <tbody>
        <tr>
            <th>操作人</th>
            <th>时间</th>
            <th>描述</th>
        </tr>
        <c:forEach items="${cbsServiceLogList}" var="log" varStatus="stat">
            <c:if test="${!stat.last}">
                <tr>
                    <td>${log.createName}</td>
                    <td>${log.createDate}</td>
                    <td>${log.description}</td>
                </tr>
            </c:if>
        </c:forEach>
        </tbody>
    </table>
</div>
</body>
<script>
    //服务商商务派单
    function findEngineer(planIds) {
        if (judge()) {
            $.ajax({
                url: "cbsServiceAssignListController.do?inspect",
                data: {
                    "planIds": planIds
                },
                cache: false,
                dataType: 'json',
                type: 'POST',
                async: false,
                beforeSend: function () {
                    lockmask(true);
                },
                success: function (data) {
                    if (data.success) {
                        createwindow("分派", "cbsServiceAssignListController.do?findEngineerPeopleList&planIds=" + planIds, 600, 500);
                    } else {
                        tip(data.msg);
                    }
                },
                complete: function () {
                    lockmask(false);
                }
            });
        } else {
            tip("操作人与派单人不符，请刷新系统！");
        }

    }

    /*判断派单人是否是当前登录人*/
    function judge() {
        var cbsId = $("#cbsId").val();
        var flag = false;
        $.ajax({
            url: "cbsServiceController.do?judgePeople",
            data: {
                "cbsId": cbsId,
                "type": "1"
            },
            async: false,
            cache: false,
            dataType: 'json',
            type: 'POST',
            error: function () {// 请求失败处理函数
            },
            success: function (data) {
                if (data.success) {
                    flag = true;
                }
            }
        });
        return flag;
    }


    //拒绝
    function refuseEngineer(planIds) {
        if (judge()) {
            $.ajax({
                url: "cbsServiceAssignListController.do?inspectRefuse",
                data: {
                    "planIds": planIds
                },
                cache: false,
                dataType: 'json',
                type: 'POST',
                async: true,
                beforeSend: function () {
                    lockmask(true);
                },
                success: function (data) {
                    if (data.success) {
                        createwindow("拒绝", "cbsServiceAssignListController.do?refuseEngineerPeopleList&planIds=" + planIds, 300, 200);
                    } else {
                        tip(data.msg);
                    }
                },
                complete: function () {
                    lockmask(false);
                }
            });
        } else {
            tip("操作人与派单人不符，请刷新系统！");
        }

    }

    function downloadFile(fileId) {
        myDownload("fileUploadController.do?downLoadFile&fileLogId=" + fileId + "");
    }
    
      //查看完工报告
    function checkCompletionReport() {
        var speedStatus = '${cbsService.speed}';
        var cbsId = '${cbsService.id }';
        //至少有一次上门签到记录
        $.ajax({
            url: "cbsServiceAssignListController.do?doorToDoorCheckIn",
            data: {
                "id": cbsId
            },
            cache: false,
            dataType: 'json',
            async: false,
            type: 'POST',
            success: function (data) {
                if (data.success) {
                    //判断服务类型，根据服务类型不同，跳转不同的完工单页面
                    var type = data.attributes['type'];
                    // alert("服务单类" + type);
                    console.info("服务单类" + type);
                    if (type == 'type-yqfx') {  //
                        addOneTab('引擎翻新现场检测完工单', 'cbsServiceReportController.do?goEngineRefurbished&id=' + cbsId);
                    }
                    if (type == 'type-yqfxys') {  //
                        addOneTab('引擎翻新验收单详情', 'cbsServiceReportController.do?goEngineRefurbishedSignDetail&id=' + cbsId);
                    }
                    if (type == 'type-ggfx') {
                        addOneTab('光管翻新验收单', 'cbsServiceReportController.do?goLighttubeAcceptanceDetail&id=' + cbsId);
                    }
                    if (type == 'type-jszc') {
                        addOneTab('技术支持完工单', 'cbsServiceReportController.do?goTechnologyAgreeDetail&id=' + cbsId);
                    }
                    if (type == 'type-wx') {
                        $.ajax({
                            url: "cbsServiceReportController.do?goTemporaryPageOnSubmit",
                            data: {
                                "id": cbsId
                            },
                            cache: false,
                            dataType: 'json',
                            async: false,
                            type: 'POST',
                            success: function (data) {
                                var attributes = data.attributes;

                                if (attributes.reportCategory == -1) {
                                    tip("尚未提交完工单");
                                    return false;
                                } else {
                                    addOneTab('完工报告', 'cbsServiceReportController.do?lookFinishReport&id=' + cbsId);
                                }
                            }
                        })

                    }
                    if (type == 'type-yj') {
                        $.ajax({
                            url: "cbsDelinerController.do?jumpPage",
                            data: {"id": cbsId},
                            async: false,
                            cache: false,
                            dataType: 'json',
                            type: 'POST',
                            success: function (data) {
                                if ("type-yj" == data.msg) {
                                    addOneTab('现场检测完工单详情', 'cbsServiceReportController.do?goReferDetectionDetail&id=' + cbsId);
                                }
                                if ("type-yqfx" == data.msg) {
                                    addOneTab('引擎翻新现场检测完工单详情', 'cbsServiceReportController.do?goEngineRefurbishedDetail&id=' + cbsId);
                                }
                                if ("尚未提交完工单" == data.msg) {
                                    tip(data.msg);
                                }
                            }
                        });
                    }

                } else {
                    tip(data.msg);
                }
            }
        });
    }
</script>
</html>
